﻿<%@ Page Language="C#" MasterPageFile="~/Template.master" AutoEventWireup="true"
    CodeFile="Product.aspx.cs" Inherits="Product" EnableViewState="false" Culture="auto"
    meta:resourcekey="PageResource1" UICulture="auto" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>
<%@ Register Assembly="Winthusiasm.HtmlEditor" Namespace="Winthusiasm.HtmlEditor"
    TagPrefix="cc2" %>
<%@ Register Src="Controls/Reviews.ascx" TagName="Reviews" TagPrefix="uc1" %>
<%@ Register Src="Controls/ImageGallery.ascx" TagName="ImageGallery" TagPrefix="uc2" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">

    <script type="text/javascript" src="Scripts/GeneralScripts.js"></script>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <asp:ScriptManager EnablePageMethods="True" ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:MultiView ID="ProductMV" runat="server" ActiveViewIndex="0">
        <asp:View ID="View1" runat="server">
            <% if (Roles.IsUserInRole("Administrator"))
               { %>
            <div>
                <a href=''>
                    <asp:Image runat="server" ID="BackImg" SkinID="BackImage" />
                </a><a href=''>
                    <asp:Image ID="ForwardImg" runat="server" SkinID="ForwardImage" />
                </a>
                <asp:ImageButton ID="EditImage" runat="server" SkinID="EditButton" OnClick="EditButton_Click" />
            </div>
            <% } %>
            <div class="item">
                <h5>
                    <asp:Label runat="server" ID="ProductTitle" />
                </h5>
                <div class="body">
                    <uc2:ImageGallery ID="ImgGalery" runat="server" />
                    <div class="floatbox" style="height: 320px; width: auto">
                        <div class="subcolumns">
                            <div class="c50l">
                                <b>
                                    <asp:Label runat="server" meta:resourcekey="ManufacturerLabel" /></b>
                            </div>
                            <div class="c50r">
                                <asp:Label ID="ManufacturerTitle" runat="server"></asp:Label>
                            </div>
                        </div>
                        <div class="subcolumns">
                            <div class="c50l">
                                <b>
                                    <asp:Literal runat="server" meta:resourcekey="WarrantyLabel" /></b>
                            </div>
                            <div class="c50r">
                                <asp:Label ID="WarrantyTime" runat="server"></asp:Label>
                            </div>
                        </div>
                        <div class="subcolumns">
                            <div class="c50l">
                                <b>
                                    <asp:Literal runat="server" meta:resourcekey="ShippingWeightLabel" /></b>
                            </div>
                            <div class="c50r">
                                <asp:Label ID="ShippingWeight" runat="server"></asp:Label>
                            </div>
                        </div>
                        <div class="subcolumns">
                            <div class="c50l">
                                <b>
                                    <asp:Literal runat="server" meta:resourcekey="ShippingCostLabel" /></b>
                            </div>
                            <div class="c50r">
                                <asp:Label ID="ShippingCost" runat="server"></asp:Label>
                            </div>
                        </div>
                        <div class="subcolumns">
                            <div class="c50l">
                                <b>
                                    <asp:Literal runat="server" meta:resourcekey="RatingLabel" /></b>
                            </div>
                            <div class="c50r">
                                <ajax:Rating Style="float: left;" CurrentRating="0" BehaviorID="RatingBehavior1"
                                    ID="UserRating" runat="server" StarCssClass="ratingStar" WaitingStarCssClass="savedRatingStar"
                                    FilledStarCssClass="filledRatingStar" EmptyStarCssClass="emptyRatingStar" ReadOnly="True">
                                </ajax:Rating>
                            </div>
                        </div>
                        <div class="subcolumns">
                            <div class="c50l">
                                <b>
                                    <asp:Literal runat="server" meta:resourcekey="PriceLabel" /></b>
                            </div>
                            <div class="c50r">
                                <asp:Label ID="Price" runat="server"></asp:Label>
                            </div>
                        </div>
                        <% if (Roles.IsUserInRole("Administrator"))
                           { %>
                        <div class="subcolumns">
                            <div class="c50l">
                                <b>
                                    <asp:Label runat="server" meta:resourcekey="DealerPriceLabel" /></b>
                            </div>
                            <div class="c50r">
                                <asp:Label ID="DealerPrice" runat="server"></asp:Label>
                            </div>
                        </div>
                        <div class="subcolumns">
                            <div class="c50l">
                                <b>
                                    <asp:Label runat="server" meta:resourcekey="WholesalePriceLabel"></asp:Label></b>
                            </div>
                            <div class="c50r">
                                <asp:Label ID="WholesaleDealerPrice" runat="server"></asp:Label>
                            </div>
                        </div>
                        <% } %>
                        <div class="subcolumns">
                            <div class="c50l">
                                <b>
                                    <asp:Literal runat="server" meta:resourcekey="AvailabilityCheckLabel" /></b>
                            </div>
                            <div class="c50r">
                                <asp:HyperLink runat="server" meta:resourcekey="AvailabilityCheckLink" ID="AvailabilityCheckLink"
                                    NavigateUrl="~/AvailabilityCheck.aspx?id={0}" Target="_blank" />
                            </div>
                        </div>
                        <div class="subcolumns">
                            <div class="c50l">
                            </div>
                            <div class="c50r">
                                <asp:ImageButton runat="server" SkinID="BuyButton" ID="BuyButton" OnClick="BuyButton_Click"
                                    meta:resourcekey="BuyButton" />
                            </div>
                        </div>
                    </div>
                </div>
                <div class="floatbox">
                    <div class="body">
                        <ajax:TabContainer ID="ProductTabs" runat="server" ActiveTabIndex="0">
                            <ajax:TabPanel ID="DescriptionTab" Width="600px" runat="server" meta:resourcekey="DescriptionTab">
                                <ContentTemplate>
                                    <div class="body paper">
                                        <asp:Literal ID="ProductDescriptionPanel" runat="server" />
                                        <h4>
                                            <asp:Literal runat="server" meta:resourcekey="FeaturesTitleLabel" />
                                        </h4>
                                        
                                        <asp:Literal ID="ProductFeaturesPanel" runat="server" />
                                        <br />
                                        <h4>
                                            <asp:Literal runat="server" meta:resourcekey="SpecsTitleLabel" />
                                        </h4>
                                        
                                        <asp:Literal ID="ProductSpecsPanel" runat="server" />
                                    </div>
                                </ContentTemplate>
                            </ajax:TabPanel>
                            <ajax:TabPanel ID="ReviewsTab" runat="server" meta:resourcekey="ReviewsTab">
                                <ContentTemplate>
                                    <div class="body paper">
                                        <uc1:Reviews runat="server" />
                                    </div>
                                </ContentTemplate>
                            </ajax:TabPanel>
                        </ajax:TabContainer>
                    </div>
                </div>
            </div>
        </asp:View>
        <asp:View runat="server">
            <div>
                <asp:ImageButton OnClientClick="SaveHTMLEditors()" ID="SaveAndBackButton" SkinID="BackButton"
                    runat="server" OnClick="SaveAndBackButton_Click" meta:resourcekey="SaveAndBackButtonResource1" />
                <asp:ImageButton OnClientClick="SaveHTMLEditors()" ID="SaveAndContinueButton" runat="server"
                    SkinID="ForwardButton" OnClick="SaveAndContinueButton_Click" meta:resourcekey="SaveAndContinueButtonResource1" />
                <asp:Button ID="SaveButton" OnClientClick="SaveHTMLEditors()" runat="server" OnClick="SaveButton_Click"
                    meta:resourcekey="SaveButton" />
            </div>
            <h3>
                <asp:TextBox Width="500px" ID="ProductTitleEdit" runat="server" meta:resourcekey="ProductTitleEditResource1" />
            </h3>
            <div>
                <uc2:ImageGallery ID="ImgGalery1" runat="server" />
                <div class="floatbox" style="height: 320px; width: auto">
                    <div class="subcolumns">
                        <div class="c50l">
                            <b>
                                <asp:Label runat="server" meta:resourcekey="ManufacturerLabel" /></b>
                        </div>
                        <div class="c50r">
                            <asp:TextBox ID="ManufacturerTitleEdit" runat="server" meta:resourcekey="ManufacturerTitleEditResource1"></asp:TextBox>
                            <ajax:AutoCompleteExtender ID="BrandList_AutoCompleteExtender" runat="server" MinimumPrefixLength="1"
                                CompletionListCssClass="autocomplete_completionListElement" CompletionListItemCssClass="autocomplete_listItem"
                                CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem" DelimiterCharacters=";, :"
                                ServiceMethod="GetBrandList" Enabled="True" ServicePath="~/WebServices/AutoComplete.asmx"
                                TargetControlID="ManufacturerTitleEdit" />
                        </div>
                    </div>
                    <div class="subcolumns">
                        <div class="c50l">
                            <b>
                                <asp:Literal runat="server" meta:resourcekey="WarrantyLabel" /></b>
                        </div>
                        <div class="c50r">
                            <asp:TextBox ID="WarrantyTimeEdit" runat="server"></asp:TextBox>
                            <ajax:AutoCompleteExtender ID="WarrantyListExtender" runat="server" MinimumPrefixLength="1"
                                CompletionListCssClass="autocomplete_completionListElement" CompletionListItemCssClass="autocomplete_listItem"
                                CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem" DelimiterCharacters=";, :"
                                ServiceMethod="GetWarrantyList" Enabled="True" ServicePath="~/WebServices/AutoComplete.asmx"
                                TargetControlID="WarrantyTimeEdit" />
                        </div>
                    </div>
                    <div class="subcolumns">
                        <div class="c50l">
                            <b>
                                <asp:Literal runat="server" meta:resourcekey="ShippingWeightLabel" /></b>
                        </div>
                        <div class="c50r">
                            <asp:TextBox ID="ShippingWeightEdit" runat="server"></asp:TextBox>
                            <ajax:FilteredTextBoxExtender ID="ShippingWeightEdit_FilteredTextBoxExtender" runat="server"
                                Enabled="True" TargetControlID="ShippingWeightEdit" FilterType="Custom, Numbers"
                                ValidChars=".">
                            </ajax:FilteredTextBoxExtender>
                        </div>
                    </div>
                    <div class="subcolumns">
                        <div class="c50l">
                            <b>
                                <asp:Literal runat="server" meta:resourcekey="ShippingCostLabel" /></b>
                        </div>
                        <div class="c50r">
                            <asp:TextBox ID="ShippingCostEdit" runat="server"></asp:TextBox>
                            <ajax:FilteredTextBoxExtender ID="ShippingCostEdit_FilteredTextBoxExtender" runat="server"
                                Enabled="True" TargetControlID="ShippingCostEdit" FilterType="Custom, Numbers"
                                ValidChars=".">
                            </ajax:FilteredTextBoxExtender>
                        </div>
                    </div>
                    <div class="subcolumns">
                        <div class="c50l">
                            <b>
                                <asp:Literal runat="server" meta:resourcekey="RatingLabel" /></b>
                        </div>
                        <div class="c50r">
                            <ajax:Rating Style="float: left;" CurrentRating="0" BehaviorID="RatingBehavior1"
                                ID="UserRating1" runat="server" StarCssClass="ratingStar" WaitingStarCssClass="savedRatingStar"
                                FilledStarCssClass="filledRatingStar" EmptyStarCssClass="emptyRatingStar" ReadOnly="True">
                            </ajax:Rating>
                        </div>
                    </div>
                    <div class="subcolumns">
                        <div class="c50l">
                            <b>
                                <asp:Literal runat="server" meta:resourcekey="PriceLabel" /></b>
                        </div>
                        <div class="c50r">
                            <asp:TextBox ID="PriceEdit" runat="server"></asp:TextBox>
                            <ajax:FilteredTextBoxExtender ID="PriceEdit_FilteredTextBoxExtender" runat="server"
                                Enabled="True" TargetControlID="PriceEdit" FilterType="Custom, Numbers" ValidChars=".">
                            </ajax:FilteredTextBoxExtender>
                        </div>
                    </div>
                    <div class="subcolumns">
                        <div class="c50l">
                            <b>
                                <asp:Label runat="server" meta:resourcekey="DealerPriceLabel" /></b>
                        </div>
                        <div class="c50r">
                            <asp:TextBox ID="DealerPriceEdit" runat="server"></asp:TextBox>
                            <ajax:FilteredTextBoxExtender ID="DealerPriceEdit_FilteredTextBoxExtender" runat="server"
                                Enabled="True" TargetControlID="DealerPriceEdit" FilterType="Custom, Numbers"
                                ValidChars=".">
                            </ajax:FilteredTextBoxExtender>
                        </div>
                    </div>
                    <div class="subcolumns">
                        <div class="c50l">
                            <b>
                                <asp:Label runat="server" meta:resourcekey="WholesalePriceLabel"></asp:Label></b>
                        </div>
                        <div class="c50r">
                            <asp:TextBox ID="WholesaleDealerPriceEdit" runat="server"></asp:TextBox>
                            <ajax:FilteredTextBoxExtender ID="WholesaleDealerPriceEdit_FilteredTextBoxExtender"
                                runat="server" Enabled="True" TargetControlID="WholesaleDealerPriceEdit" FilterType="Custom, Numbers"
                                ValidChars=".">
                            </ajax:FilteredTextBoxExtender>
                        </div>
                    </div>
                    <div class="subcolumns">
                        <div class="c50l">
                            <b>
                                <asp:Label runat="server" meta:resourcekey="CategoryTitleLabel" /></b>
                        </div>
                        <div class="c50r">
                            <asp:TextBox runat="server" ID="CategoryTextBox" />
                            <asp:HiddenField runat="server" ID="CategoryIdField" />
                        </div>
                    </div>
                    <div class="subcolumns">
                        <div class="c50l">
                            <b>
                                <asp:Label runat="server" meta:resourcekey="FeaturedLabel" /></b>
                        </div>
                        <div class="c50r" style="z-index: -1">
                            <asp:CheckBox runat="server" ID="FeaturedCheckBox" />
                        </div>
                    </div>
                    <div class="subcolumns">
                        <div class="c50l">
                        </div>
                        <div class="c50r">
                            <asp:ImageButton runat="server" SkinID="BuyButton" OnClick="BuyButton_Click" meta:resourcekey="BuyButton" />
                        </div>
                    </div>
                </div>
            </div>
            <div runat="server" id="MenuPanel" class="DropDownMenu">
                <div id="submenu">
                    <asp:Menu runat="server" ID="CategoriesMenu" DataSourceID="XMLMenu">
                        <DataBindings>
                            <asp:MenuItemBinding DataMember="Menu" NavigateUrlField="url" TextField="text" ValueField="text" />
                            <asp:MenuItemBinding DataMember="Submenu" NavigateUrlField="url" TextField="text"
                                ValueField="text" />
                        </DataBindings>
                    </asp:Menu>
                    <asp:XmlDataSource EnableCaching="false" TransformFile="~/XSLT/TransformMenuXML.xslt" XPath="MenuItems/MenuItem" runat="server" ID="XMLMenu" />
                </div>
            </div>
            <ajax:PopupControlExtender ID="PopEx" runat="server" TargetControlID="CategoryTextBox"
                PopupControlID="MenuPanel" Position="Bottom" />
            <div class="floatbox">
                <ajax:TabContainer runat="server" ActiveTabIndex="0">
                    <ajax:TabPanel Width="600px" runat="server" meta:resourcekey="DescriptionTab">
                        <ContentTemplate>
                            <div>
                                <cc2:HtmlEditor ID="DescriptionEditor" runat="server" ToggleMode="ToggleButton" ToolbarButtonsBottom="Bold,Italic,Underline,Left,Center,Right,Justify,OrderedList,BulletedList,Indent,Outdent,Rule,Subscript,Superscript,Link,Image,Save"
                                    BackColor="White" ButtonMouseOverBorderColor="Black" ButtonMouseOverColor="LightYellow"
                                    ContextChanged="" EditorBackColor="White" EditorBorderColor="SteelBlue" EditorForeColor="Black"
                                    Height="300px" meta:resourcekey="DescriptionEditorResource1" ModifiedChanged=""
                                    SelectedTabBackColor="SteelBlue" TabBackColor="LightSteelBlue" TabbarBackColor="White"
                                    TabForeColor="LightYellow" TabMouseOverColor="LightBlue" Text="" ToolbarColor="SteelBlue"
                                    Width="500px" />
                            </div>
                            <div class="ProductDescriptionsTitle">
                                <asp:Literal runat="server" meta:resourcekey="FeaturesTitleLabel" />
                            </div>
                            <div class="ProductDescriptions">
                                <cc2:HtmlEditor ID="FeaturesEditor" runat="server" ToggleMode="ToggleButton" ToolbarButtonsBottom="Bold,Italic,Underline,Left,Center,Right,Justify,OrderedList,BulletedList,Indent,Outdent,Rule,Subscript,Superscript,Link,Image,Save"
                                    BackColor="White" ButtonMouseOverBorderColor="Black" ButtonMouseOverColor="LightYellow"
                                    ContextChanged="" EditorBackColor="White" EditorBorderColor="SteelBlue" EditorForeColor="Black"
                                    Height="300px" meta:resourcekey="FeaturesEditorResource1" ModifiedChanged=""
                                    SelectedTabBackColor="SteelBlue" TabBackColor="LightSteelBlue" TabbarBackColor="White"
                                    TabForeColor="LightYellow" TabMouseOverColor="LightBlue" Text="" ToolbarColor="SteelBlue"
                                    Width="500px" />
                            </div>
                            <br />
                            <div class="ProductDescriptionsTitle">
                                <asp:Literal runat="server" meta:resourcekey="SpecsTitleLabel" />
                            </div>
                            <div class="ProductDescriptions">
                                <cc2:HtmlEditor ID="SpecsEditor" runat="server" ToggleMode="ToggleButton" ToolbarButtonsBottom="Bold,Italic,Underline,Left,Center,Right,Justify,OrderedList,BulletedList,Indent,Outdent,Rule,Subscript,Superscript,Link,Image,Save"
                                    BackColor="White" ButtonMouseOverBorderColor="Black" ButtonMouseOverColor="LightYellow"
                                    ContextChanged="" EditorBackColor="White" EditorBorderColor="SteelBlue" EditorForeColor="Black"
                                    Height="300px" meta:resourcekey="SpecsEditorResource1" ModifiedChanged="" SelectedTabBackColor="SteelBlue"
                                    TabBackColor="LightSteelBlue" TabbarBackColor="White" TabForeColor="LightYellow"
                                    TabMouseOverColor="LightBlue" Text="" ToolbarColor="SteelBlue" Width="500px" />
                            </div>
                        </ContentTemplate>
                    </ajax:TabPanel>
                    <ajax:TabPanel runat="server" meta:resourcekey="ReviewsTab">
                        <ContentTemplate>
                            <uc1:Reviews runat="server" />
                        </ContentTemplate>
                    </ajax:TabPanel>
                </ajax:TabContainer>
            </div>
        </asp:View>
    </asp:MultiView>
    <% if (Roles.IsUserInRole("Administrator"))
       { %>

    <script type="text/javascript" language="javascript">
   
    function setCategory(id, name)
    {
        var textBox = document.getElementById('<%= CategoryTextBox.ClientID %>');
        var categoryIdField = document.getElementById('<%= CategoryIdField.ClientID %>');
        categoryIdField.value = id;
        textBox.value = name;
    }
    function SaveHTMLEditors()
    {
        var e1 = $find('<%= DescriptionEditor.ClientID %>');
        var e2 = $find('<%= FeaturesEditor.ClientID %>');
        var e3 = $find('<%= SpecsEditor.ClientID %>');
        if (e1 != null)
            e1.Save();
        else
            alert("Cannot save description");
        if (e2 != null)
            e2.Save();
        else
            alert("Cannot save features");
        if (e3 != null)
            e3.Save();
        else
            alert("Cannot save specs");
    }
    </script>

    <% } %>
</asp:Content>
